package com.blue.waffle.iwc.screens;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.scenes.scene2d.Action;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Scaling;
import com.blue.waffle.iwc.game.IWCGame;


public class SplashScreen extends AbstractScreen {

	private Image splashImage;
	
	public SplashScreen(IWCGame game) {
		super(game);
	}
	
	@Override
	public void show() {
		super.show();
		
		AtlasRegion splashRegion=getTextureAtlas().findRegion("SplashScreen");
		Drawable splashDrawable=new TextureRegionDrawable(splashRegion);
		splashImage=new Image(splashDrawable, Scaling.stretch);
		splashImage.setFillParent(true);
		splashImage.getColor().a=0f;
		
		splashImage.addAction(Actions.sequence(Actions.fadeIn(0.75f),Actions.delay(1.75f),Actions.fadeOut(0.75f),new Action() {
			
			@Override
			public boolean act(float delta) {
				Gdx.app.log("splash", "finished");
				game.setScreen(new LoadingScreen(getGame()));
				
				return true;
			}
		}));
		gameStage.addActor(splashImage);
	}
	
}
